package game.model;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fank
 * @date 2018-08-28 9:46
 * @desc 小游戏结果
 **/
public class MGame {
    /**小游戏翻牌序列*/
    private List<Integer> sequen;
    /**花/镖 数值*/
    private float scope;
    /**总得分*/
    private long totalFen;
    private MType type;
    /**押注*/
    private long totalBet;
    /**本次小游戏玩家，点击的位置序列*/
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<Integer> position;

    public MGame() {
    }

    public MGame(long totalBet) {
        this.totalBet = totalBet;
    }

    public void update(MType mType, float scope, long mfen, List<MType> list) {
        this.type = mType;
        this.scope = scope;
        this.totalFen = mfen;
        this.sequen = new ArrayList<>();
        list.forEach(mType1 -> sequen.add(mType1.ordinal()));
    }

    /**
     * 玩家先择的格子
     * */
    public boolean select(int index) {
        if (position == null) {
            position = new ArrayList<>();
        }
        position.add(index);
        return position.size() - 1 == sequen.size();
    }

    public MGameVo toVo() {
        MGameVo vo = new MGameVo();
        vo.setPosition(this.position);
        vo.setScope(this.scope);
        vo.setSequen(this.sequen);
        return vo;
    }

    public List<Integer> getSequen() {
        return sequen;
    }

    public void setSequen(List<Integer> sequen) {
        this.sequen = sequen;
    }

    public float getScope() {
        return scope;
    }

    public void setScope(float scope) {
        this.scope = scope;
    }

    public long getTotalFen() {
        return totalFen;
    }

    public void setTotalFen(long totalFen) {
        this.totalFen = totalFen;
    }

    public MType getType() {
        return type;
    }

    public void setType(MType type) {
        this.type = type;
    }

    public List<Integer> getPosition() {
        return position;
    }

    public void setPosition(List<Integer> position) {
        this.position = position;
    }

    public long getTotalBet() {
        return totalBet;
    }

    public void setTotalBet(long totalBet) {
        this.totalBet = totalBet;
    }
}
